#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int g_val=10000;
int main()
{
    printf("I am father process,pid:%d,ppid:%d,g_val:%d\n",getpid(),getppid(),g_val);
    sleep(2);
    pid_t id= fork();
    if(id==0)//子进程
    {
        while(1)
        {
            printf("I am child process,pid:%d,ppid:%d,g_val:%d\n",getpid(),getppid(),g_val);
            sleep(1);
        }
    }
    else{
        while(1)
        {
            printf("I am father process,pid:%d,ppid:%d,g_val:%d\n",getpid(),getppid(),g_val);
            sleep(1);
        }
    }
    return 0;
}
